# config文件主要用来配置信息
from datetime import timedelta

import logging
from redis import StrictRedis


# 基类配置信息
class Config(object):
    DEBUG = True
    SECRET_KEY = "dsdsadasda"
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/api"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 每当改变数据库的内容之后,当视图函数结束的时候都会自动提交
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    SESSION_TYPE = "redis"
    SESSION_USE_SIGNER = True
    # 连接redis服务器
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    PERMANENT_SESSION_LIFETIME = timedelta(days=2)
    # 默认日志级别
    LEVEL_NAME = logging.DEBUG


# 开发环境配置信息
class DevelopConfig(Config):
    pass


# 生产（线上）环境配置信息
class ProductConfig(Config):
    DEBUG = False
    LEVEL_NAME = logging.ERROR


# 测试环境配置信息
class TestConfig(Config):
    pass

# 提供一个同统一的访问入口
config_dict = {
    "develop": DevelopConfig,
    "product": ProductConfig,
    "test": TestConfig
}
